Skip to content

Conversation

drewcassidy
Copy link
Member

@drewcassidy drewcassidy commented Aug 6, 2025

This is a breaking change (so the version would change to 0.1.0 or even 1.0.0).

Docs build for this branch: https://kspbuildtools.readthedocs.io/en/msbuild-refactor/

The goals here were:

  • eliminating the double-import of the .csproj.user file. Instead, this branch means that the path to KSP root never gets referenced in the user .csproj at all, allowing all the path determination to be calculated at runtime
  • eliminating risk of namespace-collision with other frameworks for property names
  • allowing toggling each component of KSPBT, to account for weird use cases, such as...
  • allowing building mods for use in the Unity editor, such as UI code, by automatically disabling all the references that are unsafe there. Its up to the mod developer still to set up preprocessor directives and includes to allow compilation in this situation, but it eliminates any need for keeping code the same between the main mod codebase and "stub" cs files just to get serialization working

Changelog:

  • Renamed global msbuild properties to have the KSPBT_ prefix to avoid namespace collisions with other frameworks
    • KSPRoot is now KSPBT_GameRoot. It should no longer be referenced within a .csproj file
    • RepoRootPath is now KSPBT_ModRoot, and should now point to the mod folder within GameData rather than the
      root of a git repo
    • BinariesOutputRelativePath is now KSPBT_ModPluginFolder
    • GenerateKSPAssemblyAttribute is now KSPBT_GenerateAssemblyAttribute and defaults to true
    • GenerateKSPAssemblyDependencyAttributes is now KSPBT_GenerateDependencyAttributes and defaults to true
    • ReferenceUnityAssemblies is now KSPBT_ReferenceUnityAssemblies
    • ReferenceKSPAssemblies is now KSPBT_ReferenceGameAssemblies
  • Added the KSPBT_ReferenceSystemAssemblies property to control referencing the mono system DLLs within the KSP
    managed folder. Setting this property to false will load the implicit framework DLLs instead.
  • Mod dependencies should now be declared with
    ModReference items. This avoids the need for the KSP install path to be known at evaluation time.

and recommend not using KSPBT_GameRoot in csproj
For building for use in the unity editor, handy for UIs!
All properties and most items are now documented. dependencies page now recommends using `ModReference`
@drewcassidy drewcassidy requested a review from JonnyOThan August 6, 2025 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant